public class LisnkList {
    //回文链表的模拟实现；
    //进行设置单链表的内部类；
    static class ListNode {
        public int val;
        public ListNode next;

        public ListNode(int val) {
            this.val = val;
        }
    }

    public ListNode head;

    public  boolean fun() {
        //1，进行寻找中间节点；
        ListNode slow = head;
        ListNode fast = head;
        while (fast != null && fast.next != null) {
            slow = slow.next;
            fast = fast.next.next;
        }
        //程序执行到此处说明slow就是中间节点；
        ListNode cur = slow.next;
        //进行翻转后半部分的单链表；
        while (cur != null) {
            ListNode curNext = cur.next;
            cur.next = slow;
            slow = cur;
            cur = curNext;
        }
        //程序执行到这里说明翻转单链表成功；
        //3.进行整体判断该单链表是否的回文链表；
        while (fast != slow) {
            if (fast.next == slow) {
                return true;
            }
            if (fast.val == slow.val) {
                return false;
            }
            fast = fast.next;
            slow = slow.next;
        }
        return true;
    }
}
